package com.jwsoft.manager.common.vo.eduDyjyQuerySync;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
public class DySyncResult {

	private Boolean success;

	private Integer code;

	private String message;

	private Map<String, Object> data = new HashMap<String, Object>();

	private DySyncResult(){}

	public static DySyncResult ok(){
		DySyncResult r = new DySyncResult();
		r.setSuccess(DySyncResultCodeEnum.SUCCESS.getSuccess());
		r.setCode(DySyncResultCodeEnum.SUCCESS.getCode());
		r.setMessage(DySyncResultCodeEnum.SUCCESS.getMessage());
		return r;
	}

	public static DySyncResult error(){
		DySyncResult r = new DySyncResult();
		r.setSuccess(DySyncResultCodeEnum.UNKNOWN_REASON.getSuccess());
		r.setCode(DySyncResultCodeEnum.UNKNOWN_REASON.getCode());
		r.setMessage(DySyncResultCodeEnum.UNKNOWN_REASON.getMessage());
		return r;
	}

	public static DySyncResult setResult(DySyncResultCodeEnum resultCodeEnum){
		DySyncResult r = new DySyncResult();
		r.setSuccess(resultCodeEnum.getSuccess());
		r.setCode(resultCodeEnum.getCode());
		r.setMessage(resultCodeEnum.getMessage());
		return r;
	}

	public DySyncResult success(Boolean success){
		this.setSuccess(success);
		return this;
	}

	public DySyncResult message(String message){
		this.setMessage(message);
		return this;
	}

	public DySyncResult code(Integer code){
		this.setCode(code);
		return this;
	}

	public DySyncResult data(String key, Object value){
		this.data.put(key, value);
		return this;
	}

	public DySyncResult data(Map<String, Object> map){
		this.setData(map);
		return this;
	}
}
